<?php

namespace app\common\model;

use think\Model;

class Type extends Model {

    /**
     * 分类列表
     */
    public function getList() {
        $list = $this->order('pid asc,list_order asc')->select();
        foreach ($list as &$row) {
            if (!$row->display) {
                $row->iconSkin = '_hide_';
            }
        }
        return $list;
    }

    /**
     * 根据父节点id查询分类列表 
     * @param type $id
     * @param type $display
     * @return type
     */
    public function getValueByPid($id = 0, $display = 1) {

        if ($display) {
            return $this->where('pid', $id)->where('display', $display)->order('list_order')->column('name', 'id');
        } else {
            return $this->where('pid', $id)->order('list_order')->column('name', 'id');
        }
    }

}
